﻿#ifndef MY_TEXTEDITOR_H
#define MY_TEXTEDITOR_H

#include "imagesizedialog.h"
#include "translatedialog.h"
#include <vector>

#include <QTextEdit>
#include <QTransform>
#include <QPoint>

using namespace std;

class My_TextEditor : public QTextEdit
{
    Q_OBJECT

public:
    My_TextEditor(QWidget *parent = nullptr);

    QMenu *getContextMenu() const { return this->m_contextMenu; }

	void init();

protected:
	virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
	virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
	virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
	void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
	//virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;

signals:
    void openFile(QString);

public slots:
	void slt_verticalValueChange(int value);

	void slt_addRect(const QPoint& tlPt, const QPoint& brPt );

public:
	bool is_Hand;  //手绘制
	QTransform  m_transform;  //记录当前的坐标变换
	int m_preVBarPos;
	int m_divVBarPos;

	QPoint m_ptPress;
	QPoint m_ptRelease;

	std::vector<QRect*>  m_rectVec;

private:
    void dropImage(const QUrl &url, const QImage &image);

    bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE;
    void insertFromMimeData(const QMimeData *source)          Q_DECL_OVERRIDE;

    void contextMenuEvent(QContextMenuEvent *event)           Q_DECL_OVERRIDE;




    ImageSizeDialog *m_ImageSizeDialog = nullptr;

    QMenu *m_contextMenu = nullptr;

	
	
};

#endif // MY_TEXTEDITOR_H
